package main

import (
	"flag"
	"fmt"

	"mall/service/backend/rmq/internal/config"
	"mall/service/backend/rmq/internal/logic"

	"github.com/zeromicro/go-zero/core/conf"
	"github.com/zeromicro/go-zero/core/service"
)

var configFile = flag.String("f", "etc/backend.dev.yaml", "the config file")

func main() {
	flag.Parse()

	var c config.Config
	conf.MustLoad(*configFile, &c, conf.UseEnv())

	// log、prometheus、trace、metricsUrl
	if err := c.SetUp(); err != nil {
		panic(err)
	}

	serviceGroup := service.NewServiceGroup()
	defer serviceGroup.Stop()

	for _, mq := range logic.Mqs(c) {
		serviceGroup.Add(mq)
	}

	fmt.Printf("Starting rmq server ...\n")

	serviceGroup.Start()
}
